package com.ncp.model.entity.cart;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.jsp.jstl.sql.Result;

import com.ncp.model.dao.DB;
import com.ncp.model.dao.DbConnection;

public class CartBean {
	private DB common = new DB();
	private String productID;      // 产品编号
	private String productName;    // 产品名称
	private String productImage;  //描述图片路径
	private double marketprice;   //市场价 
	private double retailPrice;   //产品价格
	private int productNumOfCart;        // 购物车中产品数量
	public CartBean(){
		
	}
	public CartBean(String productID, int productNumOfCart) {
		super();
		String sql="select productid,productname,productimage,retailprice,marketprice from PRODUCTBASIC where productid = "+productID+"";
		common.setSql(sql);
		common.setConn(DbConnection.getConnByDataSource());
		List<Object> list=new ArrayList<Object>();
		common.setList(list);
		Result rs = common.executeQuery();
		for(Map<String,Object> object: rs.getRows()){
			this.productID = object.get("productid").toString();
			this.productName = object.get("productname").toString();
			this.productImage = object.get("productimage").toString();
			this.retailPrice = Double.parseDouble(object.get("retailPrice").toString());
			this.marketprice = Double.parseDouble(object.get("marketprice").toString());
			this.productNumOfCart = productNumOfCart;
		}
		
	}
	
	public String getProductID() {
		return productID;
	}
	public void setProductID(String productID) {
		this.productID = productID;
	}
	public String getProductName() {
		return productName;
	}
	public void setProductName(String productName) {
		this.productName = productName;
	}
	public double getRetailPrice() {
		return retailPrice;
	}
	public void setRetailPrice(double retailPrice) {
		this.retailPrice = retailPrice;
	}
	public int getProductNumOfCart() {
		return productNumOfCart;
	}
	public void setProductNumOfCart(int productNumOfCart) {
		this.productNumOfCart = productNumOfCart;
	}
	public String getProductImage() {
		return productImage;
	}
	public void setProductImage(String productImage) {
		this.productImage = productImage;
	}
	public double getMarketprice() {
		return marketprice;
	}
	public void setMarketprice(double marketprice) {
		this.marketprice = marketprice;
	}
}
